#pragma once

// Enable extra D3D debugging in debug builds if using the debug DirectX runtime.  
// This makes D3D objects work well in the debugger watch window, but slows down performance slightly
#if defined (_DEBUG)
#ifndef D3D_DEBUG_INFO
#define D3D_DEBUG_INFO
#endif
#endif

#include "phatGDI.h" // added for EditorGUI

#include <d3d9.h>
#include <d3dx9.h>


#define ReleaseCOM(x) { if(x){ x->Release();x = 0; } }

// DirectX 9 3 and 2D
class cGraphics9
{
private:
	D3DPRESENT_PARAMETERS md3dpp;
	D3DDISPLAYMODE md3dmode;
	D3DXFONT_DESC mDefaultFontDesc;

	bool bWindowed;
	bool bVsync;
	bool bZbuffer;

	int mWidth;
	int mHeight;

	public:
	
	IDirect3D9 *p_mObject;
	IDirect3DDevice9 *p_mDevice;
	ID3DXSprite *p_mSpriteHandler;    // the pointer to our Direct3D Sprite interface
	ID3DXFont* p_mDefaultText; // font Times New Roman 24 pt

	cGraphics9();
	~cGraphics9();

	bool isWindowed() const { return bWindowed; }
	bool isVsync() const { return bVsync; }
	bool isZbuffer() const { return bZbuffer; }

	int getWidth() const { return mWidth; }
	int getHeight() const { return mHeight; }

	void createD3D(HWND hWindow, bool windowed = true, bool vysnc = false , bool zbuffer = false); // Create Direct3D for 3 and 2D
	
	// default to dark blue
	void clear(int r = 0, int g = 0, int b = 212);

	// Uses 2D call between sprite drawing calls
	void drawText(string sText, int x, int y, D3DCOLOR dColor = D3DCOLOR_XRGB(255,255,255), int height = 24, string sFont = "Times New Roman", DWORD dFlags = DT_NOCLIP);

	// for 3D
	void beginScene();

	void presentScene();

	// for 2D
	void beginSpriteDrawing();

	void endSpriteDrawing();

	// default to white



};